home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Original Shareware 1.1
/
The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso
/
38
/
sgn_bans.zip
/
EDITFONT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1985-12-04
|
14KB
|
487 lines
{ EditFont.Pas, the font editor for SignSmif.Pas }
{ Start Global declarations }
Const
xtik = 16 ;
ytik = 6 ;
M : array[0..7] of byte = ($80,$40,$20,$10,$08,$04,$02,$01) ;
WM : array[0..15] of integer =
($8000,$4000,$2000,$1000,$0800,$0400,$0200,$0100,
$0080,$0040,$0020,$0010,$0008,$0004,$0002,$0001) ;
type
Font1 = array[0..255,0..7] of byte ;
Font2 = array[0..255,0..13] of byte ;
Font3 = array[0..255,0..13] of integer ;
Font4 = array[0..255,0..27] of integer ;
Var
hsize, vsize, hsp1, vsp1, nhor, nvert : integer ;
LastRow, LastCol : integer ;
TLX, TLY, BRX, BRY : integer ; { top left x, etc. }
ch, tch : char ;
bitmap : array[0..27,0..15] of byte ;
CharMap1 : Font1 ;
CharMap2 : Font2 ;
CharMap3 : Font3 ;
CharMap4 : Font4 ;
FontFile1 : file of Font1 ;
FontFile2 : file of Font2 ;
FontFile3 : file of Font3 ;
FontFile4 : file of Font4 ;
FontName : string[30] ;
FontNumber : integer ;
asc : byte ;
FuncKey : boolean ;
{ZZZ$I Hex.Pas }
Procedure LoadBitMap(a : char ) ;
Var j, k : integer ;
begin
for j := 0 to LastRow do
begin
for k := 0 to LastCol do
begin
case FontNumber of
1 : begin
if ( ( Charmap1[ord(a),j] and M[k] ) <> 0 )
then BitMap[j,k] := 1 else BitMap[j,k] := 0 ;
end ; { 1 }
2 : begin
if ( ( Charmap2[ord(a),j] and M[k] ) <> 0 )
then BitMap[j,k] := 1 else BitMap[j,k] := 0 ;
end ; { 2 }
3 : begin
if ( ( Charmap3[ord(a),j] and WM[k] ) <> 0 )
then BitMap[j,k] := 1 else BitMap[j,k] := 0 ;
end ; { 3 }
4 : begin
if ( ( Charmap4[ord(a),j] and WM[k] ) <> 0 )
then BitMap[j,k] := 1 else BitMap[j,k] := 0 ;
end ; { 4 }
end ; { case }
end ; { k }
{ writeln ; }
end ; { j }
end ;
Procedure UnLoadBitMap(a : char ) ;
Var
j, k : integer ;
bi : integer ;
bb : byte ;
begin
for j := 0 to LastRow do
begin
case FontNumber of
1 : begin
bb := 0 ;
for k := 0 to LastCol do
if BitMap[j,k] <> 0 then bb := ( bb or M[k] ) ;
CharMap1[ord(a),j] := bb ;
end ; { 1 }
2 : begin
bb := 0 ;
for k := 0 to LastCol do
if BitMap[j,k] <> 0 then bb := ( bb or M[k] ) ;
CharMap2[ord(a),j] := bb ;
end ; { 2 }
3 : begin
bi := 0 ;
for k := 0 to LastCol do
if BitMap[j,k] <> 0 then bi := ( bi or WM[k] ) ;
CharMap3[ord(a),j] := bi ;
end ; { 3 }
4 : begin
bi := 0 ;
for k := 0 to LastCol do
if BitMap[j,k] <> 0 then bi := ( bi or WM[k] ) ;
CharMap4[ord(a),j] := bi ;
end ; { 4 }
end ; { case }
end ; { j }
end ; { unload }
Procedure DrawTicks(x,y,shade : integer) ;
Var
txb,lyb : integer ;
begin
txb := tlx + x*hsp1 + hsize div 2 ;
lyb := tly + y*vsp1 + vsize div 2 ;
draw(tlx-xtik,lyb,tlx-1,lyb,shade) ; { left tick }
draw(brx+1,lyb,brx+xtik,lyb,shade) ; { right tick }
draw(txb,tly-ytik,txb,tly-1,shade) ; { top tick }
draw(txb,bry+1,txb,bry+ytik,shade) ; { bottom tick }
draw(txb+1,tly-ytik,txb+1,tly-1,shade) ; { extra top tick }
draw(txb+1,bry+1,txb+1,bry+ytik,shade) ; { & bottom tick }
end ;
Procedure MoveTicks(xold,yold,xnew,ynew : integer) ;
begin
DrawTicks(xold,yold,0) ;
DrawTicks(xnew,ynew,1) ;
end ;
Procedure FillBlock(xloc,yloc,shade : integer) ;
Var
j, k : integer ;
tlxb,tlyb,brxb,bryb,tlybj : integer ;
begin
tlxb := tlx + xloc*hsp1 + 1 ;
tlyb := tly + yloc*vsp1 + 1 ;
brxb := tlxb + hsize - 1 ;
bryb := tlyb + vsize - 1 ;
for j := tlyb to bryb do draw(tlxb,j,brxb,j,shade) ;
end ;
Procedure DrawGrid ;
Var
j, k : integer ;
begin
for j := 0 to nvert do
begin
k := tly + j*vsp1 ;
draw(tlx,k,brx,k,1) ;
end ;
for j := 0 to nhor do
begin
k := tlx + j*hsp1 ;
draw(k,tly,k,bry,1) ;
end ;
end ;
Procedure FillInTheGrid ;
Var j, k : integer ;
begin
for j := 0 to LastRow do
for k := 0 to LastCol do
FillBlock(k,j,BitMap[j,k]) ;
end ;
Procedure MakeNewCharacter ;
begin
Hires ;
HiresColor(7) ;
DrawGrid ;
FillInTheGrid ;
gotoxy(1,23) ;
Writeln('Use keypad arrow keys, Ins, Del') ;
gotoxy(1,25) ;
write('F1 for new character, F10 to exit') ;
gotoxy(54,18) ;
write('F2 = Import character') ;
gotoxy(54,19) ;
write('CAUTION - see manual') ;
gotoxy(54,21) ;
write('Flips, F3=Left-Rt, F4=Up-Dn') ;
gotoxy(54,23) ;
write('Move Entire Character') ;
gotoxy(55,24) ;
write(' (Slowly !)') ;
gotoxy(55,25) ;
write('F5=',#24,' F6=',#25,' F7=',#27,' F8=',#26) ;
end ;
{ **** ------------------------------------------------------------ }
Var
j, k, row, col, trow, tcol, newrow, newcol : integer ;
keychar : char ;
spotx, spoty, spot : integer ;
tbyte : byte ;
begin
repeat
ClrScr ;
write('What type of font do you want to edit, 1 to 4 ? ') ;
readln(FontNumber) ;
until FontNumber in [1..4] ;
tlx := 200 ; tly := 30 ;
case FontNumber of
1 : begin
hsize := 12 ; vsize := 8 ;
nHor := 8 ; nVert := 8 ;
end ; { 1 }
2 : begin
hsize := 10 ; vsize := 4 ;
nHor := 8 ; nVert := 14 ;
end ; { 2 }
3 : begin
hsize := 8 ; vsize := 6 ;
nHor := 16 ; nVert := 14 ;
end ; { 3 }
4 : begin
hsize := 8 ; vsize := 4 ;
nHor := 16 ; nVert := 28 ;
end ; { 4 }
end ; { case }
LastCol := nHor - 1 ;
LastRow := nVert - 1 ;
hsp1 := hsize + 1 ;
vsp1 := vsize + 1 ;
brx := tlx + nhor * hsp1 ;
bry := tly + nvert * vsp1 ;
clrscr ; gotoxy(1,1) ;
repeat
writeln('Enter full name of font file, including') ;
write('drive and directory if needed ') ;
readln(FontName) ;
case FontNumber of
1 : begin
assign(FontFile1,FontName) ;
{$I-}
reset(FontFile1) ;
{$I+}
end ; { 1 }
2 : begin
assign(FontFile2,FontName) ;
{$I-}
reset(FontFile2) ;
{$I+}
end ; { 2 }
3 : begin
assign(FontFile3,FontName) ;
{$I-}
reset(FontFile3) ;
{$I+}
end ; { 3 }
4 : begin
assign(FontFile4,FontName) ;
{$I-}
reset(FontFile4) ;
{$I+}
end ; { 4 }
end ; { case }
j := IOresult ;
if j <> 0 then writeln('File not found. Try again.') ;
until j = 0 ;
case FontNumber of
1 : read(FontFile1,CharMap1) ;
2 : read(FontFile2,CharMap2) ;
3 : read(FontFile3,CharMap3) ;
4 : read(FontFile4,CharMap4) ;
end ; { case }
repeat
textmode(bw80) ;
clrscr ;
gotoxy(1,1) ;
write('':75) ;
gotoxy(1,2) ;
write('':75) ;
gotoxy(1,1) ;
write('Enter character to be edited ') ;
readln(ch) ;
LoadBitMap(ch) ;
MakeNewCharacter ;
col := LastCol div 2 + 1 ; row := LastRow div 2 + 1 ;
MoveTicks(0,0,col,row) ;
repeat
funckey := false ;
{ blinking spot cursor stuff }
spotx := tlx + col*hsp1 + hsize div 2 ;
spoty := tly + row*vsp1 + vsize div 2 ;
spot := 1 - BitMap[row,col] ; { contrasting colour }
plot(spotx ,spoty ,spot) ; { make spot on cell }
plot(spotx+1,spoty ,spot) ;
plot(spotx+1,spoty+1,spot) ;
plot(spotx ,spoty+1,spot) ;
repeat until keypressed ;
spot := 1 - spot ; { remove the cursor spot }
plot(spotx ,spoty ,spot) ;
plot(spotx+1,spoty ,spot) ;
plot(spotx+1,spoty+1,spot) ;
plot(spotx ,spoty+1,spot) ;
read(KBD,keychar) ;
if (keychar = #27) and keypressed then
begin
read(KBD,keychar) ;
funckey := true ;
end ;
if funckey then
begin
newcol := col ;
newrow := row ;
if keychar in [#75,#77,#72,#80] then
begin
case(keychar) of
#75 : newcol := col - 1 ; { left }
#77 : newcol := col + 1 ; { right }
#72 : newrow := row - 1 ; { up }
#80 : newrow := row + 1 ; { down }
end ; { case }
if (newcol in [0..LastCol]) and (newrow in [0..LastRow]) then
begin
MoveTicks(col,row,newcol,newrow) ;
col := newcol ;
row := newrow ;
end
else
begin
sound(5000) ;
delay(100) ;
nosound ;
end ;
end ; { in [#75 etc }
case(keychar) of
#82 : begin { insert }
BitMap[row,col] := 1 ;
FillBlock(col,row,1) ;
end ;
#83 : begin { delete }
BitMap[row,col] := 0 ;
FillBlock(col,row,0) ;
end ;
#59,#68 : begin { F1 or F10 }
UnLoadBitMap(ch) ;
end ;
end ; { case }
if keychar in [#60..#66] then
begin
case keychar of
#60 : begin { F2, import character }
textmode(bw80) ;
clrscr ;
gotoxy(1,1) ;
write('Enter character to import in place of ',ch) ;
gotoxy(1,2) ;
write('(use period as a signal to quit). ') ;
readln(tch) ;
gotoxy(1,1) ;
write(' ') ;
gotoxy(1,2) ;
write(' ') ;
if tch <> '.' then LoadBitMap(tch) ;
MakeNewCharacter ;
MoveTicks(0,0,col,row) ;
end ; { #60 }
#61 : begin { F3, flip left-right }
for trow := 0 to LastRow do
begin
for tcol := 0 to (LastCol div 2) do
begin
tbyte := BitMap[trow,tcol] ;
BitMap[trow,tcol] := BitMap[trow,LastCol-tcol] ;
BitMap[trow,LastCol-tcol] := tbyte ;
end ; { tcol }
end ; { trow }
end ; { #61 }
#62 : begin { F4, top-bot }
for tcol := 0 to LastCol do
begin
for trow := 0 to (Lastrow div 2) do
begin
tbyte := BitMap[trow,tcol] ;
BitMap[trow,tcol] := BitMap[LastRow-trow,tcol] ;
BitMap[LastRow-trow,tcol] := tbyte ;
end ; { trow }
end ; { tcol }
end ; { #62 }
#63 : begin { F5, move up }
for trow := 1 to LastRow do
begin
for tcol := 0 to LastCol do
BitMap[trow-1,tcol] := BitMap[trow,tcol] ;
end ; { trow }
for tcol := 0 to LastCol do
BitMap[LastRow,tcol] := 0 ;
end ; { #63 }
#64 : begin { F6, move down }
for trow := LastRow downto 1 do
begin
for tcol := 0 to LastCol do
BitMap[trow,tcol] := BitMap[trow-1,tcol] ;
end ; { trow }
for tcol := 0 to LastCol do
BitMap[0,tcol] := 0 ;
end ; { #64 }
#65 : begin { F7, move left }
for trow := 0 to LastRow do
begin
for tcol := 1 to LastCol do
BitMap[trow,tcol-1] := BitMap[trow,tcol] ;
BitMap[trow,LastCol] := 0 ;
end ; { trow }
end ; { #65 }
#66 : begin { F8, move right }
for trow := 0 to LastRow do
begin
for tcol := LastCol downto 1 do
BitMap[trow,tcol] := BitMap[trow,tcol-1] ;
BitMap[trow,0] := 0 ;
end ; { trow }
end ; { #66 }
end ; { case }
FillInTheGrid ;
end ; { if keychar in [#63.. }
end ; { funckey }
until keychar in [#59,#68] ; { F1 or F10 }
until keychar = #68 ; { F10 }
repeat
gotoxy(1,1) ;
write('Update file ',FontName,' ? (y/n) ') ;
readln(ch) ;
ch := UpCase(ch) ;
until ch in ['Y','N'] ;
if ch = 'Y' then
begin
case FontNumber of
1 : begin ;
rewrite(FontFile1) ;
Write(FontFile1,CharMap1) ;
Close(FontFile1) ;
end ; { 1 }
2 : begin ;
rewrite(FontFile2) ;
Write(FontFile2,CharMap2) ;
Close(FontFile2) ;
end ; { 2 }
3 : begin ;
rewrite(FontFile3) ;
Write(FontFile3,CharMap3) ;
Close(FontFile3) ;
end ; { 3 }
4 : begin ;
rewrite(FontFile4) ;
Write(FontFile4,CharMap4) ;
Close(FontFile4) ;
end ; { 4 }
end ; { case }
end ;
textmode(bw80) ;
clrscr ;
end .